package com.hxzy.authentication.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hxzy.authentication.domain.TsDriversLicenseCertification;
import com.hxzy.authentication.domain.vo.DriversVo;
import com.hxzy.authentication.mapper.TsDriversLicenseCertificationMapper;
import com.hxzy.authentication.service.TsDriversLicenseCertificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * 驾驶证认证Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-06-23
 */

@Service
public class TsDriversLicenseCertificationServiceImpl extends ServiceImpl<TsDriversLicenseCertificationMapper, TsDriversLicenseCertification> implements TsDriversLicenseCertificationService {

    @Autowired
    private TsDriversLicenseCertificationMapper tsDriversLicenseCertificationMapper;

    @Override
    public void selectPage(Page<TsDriversLicenseCertification> page, DriversVo driversVo) {
        baseMapper.selectPage(page,
                new LambdaQueryWrapper<TsDriversLicenseCertification>()
                        //根据姓名模糊查询
                        .like(StringUtils.hasLength(driversVo.getName()), TsDriversLicenseCertification::getName, driversVo.getName())
                        //根据手机模糊查询
                        .like(StringUtils.hasLength(driversVo.getUserPhone()), TsDriversLicenseCertification::getUserPhone, driversVo.getUserPhone())
                        //根据审核人模糊查询
                        .like(StringUtils.hasLength(driversVo.getReviewer()), TsDriversLicenseCertification::getReviewer, driversVo.getReviewer())
                        //根据驾驶证有效期查询
                        .leSql(StringUtils.hasLength(driversVo.getValidPeriod()), TsDriversLicenseCertification::getValidPeriod, "CONCAT_WS('至',SUBSTRING_INDEX(valid_period,'至',1),'" +driversVo.getValidPeriod()+"')")
                        //大于申请开时间
                        .ge(StringUtils.hasLength(driversVo.getStart()), TsDriversLicenseCertification::getApplyTime, driversVo.getStart())
                        //小于申请时间
                        .le(StringUtils.hasLength(driversVo.getEnd()), TsDriversLicenseCertification::getApplyTime, driversVo.getEnd())
                        //根据审核状态模糊查询
                        .eq(!driversVo.getCertificationStatus().equals(0), TsDriversLicenseCertification::getCertificationStatus, driversVo.getCertificationStatus())
        );
    }


}
